package com.xmy.cultivate.mapper;

import com.xmy.cultivate.entity.EnrollLabel;
import com.xmy.cultivate.entity.EnrollTeam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * <p>
 * 招生战队 Mapper 接口
 * </p>
 *
 * @author min
 * @since 2023-02-10
 */
public interface EnrollTeamMapper extends BaseMapper<EnrollTeam> {

    /**
     *
     * @param
     * @return
     */
    @Select({"<script>",
            "select id,year_part,quarter_num,school_id,school_name,name,pid,status,start_date,(CASE WHEN `status` =1 THEN null ELSE end_date END) as end_date from enroll_team where pid = ${pid} and deleted=0 ",
            "<when test='yearPart!=null and yearPart!=&apos;&apos; '>",
            "and year_part = ${yearPart}",
            "</when>",
            "<when test='quarterNum!=null and quarterNum!=&apos;&apos; '>",
            "and quarter_num = ${quarterNum}",
            "</when>",
            "<when test='status!=null and status!=&apos;&apos; '>",
            "and status = ${status}",
            "</when>",
            "ORDER BY sort asc",
            "</script>"})
    public List<EnrollTeam> getTreeList(@Param("pid")Long pid,@Param("yearPart")String yearPart,@Param("quarterNum")String quarterNum,@Param("status")String status);


    @Select("select GROUP_CONCAT(`name`) as name from enroll_team where pid = ${teamId} and deleted=0 and status=1 and (start_date < '${startDate}' OR end_date > '${endDate}')")
    public  String getChilTeamAtDataName(@Param("teamId") Long teamId, @Param("startDate") String startDate,@Param("endDate") String endDate);

}
